from django.conf.urls import url
from django.contrib import admin
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

# from .views import statistical
from meiduo_admin.views import group
from meiduo_admin.views import permissions
from meiduo_admin.views import statistical,users,specs,images,skus,spus,orders,admin

urlpatterns = [
    # 登录
    url(r'^authorizations/$', obtain_jwt_token),

    # --------用户数据统计--------
    # 用户总量
    url(r'^statistical/total_count/$', statistical.UserCountView.as_view()),
    # 日增用户数量
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # 日活跃用户统计
    url(r'^statistical/day_active/$', statistical.UserActiveCountView.as_view()),
    # 日下单用户
    url(r'^statistical/day_orders/$', statistical.UserOrderCountView.as_view()),
    # 跃增用户数量
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 日分类商品访问量
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayView.as_view()),
    # --------用户管理--------
    url(r'^users/$', users.UserView.as_view()),
    # --------获取商品--------
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),
    # ---------获取SKU信息--------
    url(r"^skus/simple/$", images.ImagesView.as_view({'get': 'simple'})),
    # --------获取SPU商品规格--------
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),
    # --------获取品牌信息--------
    url(r'^goods/brands/simple/$', spus.SPUView.as_view({'get': 'simple'})),
    # --------获取商品频道信息-------
    url(r'^goods/channel/categories/$', spus.SPUView.as_view({'get': 'categories'})),
    # 二级和三级分类路由
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spus.SPUView.as_view({'get': 'grade'})),
    # --------权限路由--------
    url(r'^permission/content_types/$', permissions.PermissionView.as_view({'get': 'content_type'})),
    # --------获取权限路由--------
    url(r'^permission/simple/$', group.GroupView.as_view({'get': 'simple'})),
    # --------管理员添加组--------
    url(r'^permission/groups/simple/$', admin.AdminView.as_view({'get': 'simple'})),

]
# -------商品管理--------
router = DefaultRouter()
router.register('goods/specs', specs.SpecsView, basename='specs')
urlpatterns += router.urls

# --------图片管理--------
router = DefaultRouter()
router.register('skus/images', images.ImagesView, basename='images')
urlpatterns += router.urls

# ------SKU信息管理--------
router = DefaultRouter()
router.register('skus', skus.SKUView, basename='skus')
urlpatterns += router.urls

# ------SPU信息管理--------
router = DefaultRouter()
router.register('goods', spus.SPUView, basename='goods')
urlpatterns += router.urls

# --------订单路由--------
router = DefaultRouter()
router.register('orders', orders.OrderView, basename='orders')
urlpatterns += router.urls

# --------权限路由--------
router = DefaultRouter()
router.register('permission/perms', permissions.PermissionView, basename='perms')
print(router.urls)
urlpatterns += router.urls
# --------分组路由--------
router = DefaultRouter()
router.register('permission/groups', group.GroupView, basename='groups')
print(router.urls)
urlpatterns += router.urls

# --------管理员路由--------
router = DefaultRouter()
router.register('permission/admins',admin.AdminView, basename='admin')
print(router.urls)
urlpatterns += router.urls



